package edu.hebeu.evil.freshmenguide.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import edu.hebeu.evil.freshmenguide.R;
import uk.co.senab.photoview.PhotoView;

/********************************************
 * 工程名：FreshmenGuide
 * 包名：edu.hebeu.evil.freshmenguide.Fragment
 * 时间：16-7-28 下午9:39
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：校园风景 用于ViewPager
 ********************************************/
public class SchoolViewFragment extends Fragment
{
    private View view;

    private static SchoolViewFragment schoolViewFragment;

    private String imgURL, t,s;
    private PhotoView imageView;
    private TextView content;
    private TextView title;
    private int now, sum;

    private boolean isTextShow = true;
    private LinearLayout linearLayout;


    public static SchoolViewFragment newInstance(String imgURL, String t, int now, int sum, String s)
    {
        schoolViewFragment = new SchoolViewFragment();
        schoolViewFragment.imgURL = imgURL;
        schoolViewFragment.s = s;
        schoolViewFragment.t = t;
        schoolViewFragment.now = now;
        schoolViewFragment.sum = sum;
        return schoolViewFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
    {
        view = inflater.inflate(R.layout.schoolview_fragment, container, false);
        initView(view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
    {
        initView(view);

        Glide.with(getContext()).load(imgURL).into(imageView);
        title.setText(now + "/" + sum + "  " + t);
        content.setText(now + "/" + sum + "  " + s);

        /*content.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Utils.Log("点击2");
                if (isTextShow)
                    linearLayout.setVisibility(View.INVISIBLE);
                else
                    linearLayout.setVisibility(View.VISIBLE);
            }
        });


        imageView.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Utils.Log("点击");
                if (isTextShow)
                    linearLayout.setVisibility(View.INVISIBLE);
                else
                    linearLayout.setVisibility(View.VISIBLE);
            }
        });*/
    }

    private void initView(View view)
    {
        imageView = (PhotoView) view.findViewById(R.id.imageView);
        content = (TextView) view.findViewById(R.id.content);
        linearLayout = (LinearLayout) view.findViewById(R.id.linearLayout);
        title = (TextView) view.findViewById(R.id.title);
    }
}
